<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <meta charset="UTF-8">
    <th:block th:include="include :: header('PI信息详情')" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="favicon.ico">
    <link rel="stylesheet" href="../../../static/css/bootstrap.min.css" >
    <link rel="stylesheet" href="../../../static/udi/dist/css/layui.css">
    <link href="../../../static/css/font-awesome.min.css" rel="stylesheet"/>
    <!-- bootstrap-table 表格插件样式 -->
    <link href="../../../static/css/animate.css" rel="stylesheet"/>
    <link href="../../../static/css/style.css" rel="stylesheet"/>
    <link href="../../../static/udi/css/jt-ui.css" rel="stylesheet"/>
</head>
<body class="write-bg">
<div class="panel">
    <div class="panel-heading">
        <p><b>注意：</b>生产日期与有效期为六位，请按<b>年</b>（两位）<b>月</b>（两位）<b>日</b>（两位）格式进行修改（如:2021/01/01为210101）</p>
    </div>
    <div class="panel-body">
        <div class="wrapper wrapper-content animated fadeInRight ibox-content">
            <form class="form-horizontal m" id="form-gs1-edit" th:object="${PI}">
                <input hidden th:field="*{piId}">
                <div class="form-group">
                    <label class="col-sm-2 control-label is-required">部门名：</label>
                    <div class="col-sm-4">
                        <input class="form-control" type="text"  th:field="*{deptName}" readonly>
                    </div>
                    <label class="col-sm-2 control-label is-required">器械标识(DI)：</label>
                    <div class="col-sm-4">
                        <input class="form-control" type="text"  th:field="*{di}" readonly>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label is-required">生产标识(PI)：</label>
                    <div class="col-sm-10">
                        <input class="form-control" type="text" id="pi" th:field="*{pi}" readonly>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label is-required">GS1-128(UDI)：</label>
                    <div class="col-sm-10">
                        <input class="form-control" type="text" id="udi" th:field="*{udi}" readonly>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label is-required">生产日期：</label>
                    <div class="col-sm-4">
                        <input class="form-control" type="text" id="produceDate" th:field="*{produceDate}">
                    </div>
                    <label class="col-sm-2 control-label is-required">有效期至：</label>
                    <div class="col-sm-4">
                        <input class="form-control" type="text" id="validEndDate" th:field="*{validEndDate}">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label is-required">批号：</label>
                    <div class="col-sm-4">
                        <input class="form-control" type="text" id="batchNum" th:field="*{batchNum}">
                    </div>
                    <label class="col-sm-2 control-label">序列号：</label>
                    <div class="col-sm-4">
                        <input  class="form-control" type="text" id="serialNum" th:field="*{serialNum}" readonly>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var qqmyxmdm_code,scrq_code,sxrq_code,scph_code,xlh_code;
    $(function () {
        setInterval("change_pi()",500);
        //实时验证
        $("#form-gs1-edit").validate({
            onkeyup: false,
            rules:{
                num:{
                    positiveinteger: true
                }
            },
            messages: {
                num:{
                    positiveinteger: "必须输入正整数！"
                }
            },
            focusCleanup: true//当表单得到焦点时，移除在该表单上的errorClass并隐藏所有错误消息
        });
        //获取应用标识符
        $.ajax({
            url:"/gs1manage/getAi",
            type:"post",
            dataType:"json",
            success:function(res){
                if(res.code===1){
                    $.each(res.msg,function (i,o) {
                        if(o.aiInfoEn === "qqmyxmdm_code"){qqmyxmdm_code = o.ai};
                        if(o.aiInfoEn === "scrq_code"){scrq_code = o.ai};
                        if(o.aiInfoEn === "sxrq_code"){sxrq_code = o.ai};
                        if(o.aiInfoEn === "scph_code"){scph_code = o.ai};
                        if(o.aiInfoEn === "xlh_code"){scxlh_code = o.ai};
                    })
                }else{
                    layer.msg("获取应用标识符失败",{icon:6,time:1000});
                }
            }
        })
    })

    // 添加自定义校验规则，校验正整数
    $.validator.addMethod("positiveinteger", function(value, element) {
        var Val = parseInt(value);
        return Val > 0 && (Val + "") == value;
    }, "请输入正整数");

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save("/gs1manage/edit", $('#form-gs1-edit').serialize());
        }
    }
    //计时器1s执行一次
    function change_pi() {
        var pi = scrq_code+$("#produceDate").val()+sxrq_code+$("#validEndDate").val()+scph_code+$("#batchNum").val()+scxlh_code+$("#serialNum").val();
        $("#pi").attr("value",pi);
        var udi = qqmyxmdm_code+$("#di").val()+pi;
        $("#udi").attr("value",udi);
    }
</script>
</body>
</html>